<?php
namespace data\set\news;
use \data\BaseData;
/**
 * 新闻列表管理
 */
class NewsListData extends BaseData{
    
    
    
    public function getList($param){        
        $page = $param['page']?:1;
        $limit= $param['limit']?:15;
        $check = ['a.status','a.datastatus' ,'a.siteid','a.groupid','a.name'=> 'like'];
        $where = $this->parseWhere($check,$param);
        if( $param['tags'] )  $where['a.tags'] = ['like','%,'.$param['tags'].',%'];
        if( $param['keyword'] ) $where['a.name|a.des'] = ['like', '%'.$param['keyword'].'%'];
        
        $fields = 'a.id,a.siteid,a.adduserid,a.groupid,a.tags,a.status,a.datastatus,a.sort,a.addtime,a.edittime,a.pic,a.name,a.des,b.groupname';        
        $list  = M("set_news")->alias('a')->join('elite_set_news_group b','a.groupid = b.id')->field( $fields)
       // ->where('a.name',['like', '%管%']) 
        ->where($where)->order('a.sort desc,a.id desc')->page($page)->limit($limit)->select();
       // pr(M()->getLastSql());
        $total = M("set_news")->alias('a')->join('elite_set_news_group b','a.groupid = b.id')->where($where)->count();
        return [            
            'page' => $page,
            'limit' => $limit,
            'total'=> $total,
            'list' => $list,
        ];
    }
    
    
}